import Reflux from 'reflux'
import GUtils from '@/utils'
import RsaHelper from '@/utils/encrypt'

const prefix = '/pub/'
const api = {
  login: prefix + 'login',
}
/**
 *  管理员账号密码: xingcheclub77 root
 */
const createAction = () => {
  const Action = Reflux.createActions({
    login: { asyncResult: true },
  })

  Action.login.listen(function (vo) {
    vo.password = RsaHelper.doEncrypt(vo.password)
    GUtils.Ajax.post(api.login, vo).then(this.completed, this.failed)
  })
  return Action
}

export { api, createAction }
